package com.wenjie.original.entity;


import com.mybatisflex.annotation.EnumValue;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Arrays;
import java.util.Date;

@Data
@Table("sys_admin")
@ApiModel("用户对象 ")
public class SysAdmin extends BaseEntity {

    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @ApiModelProperty("用户ID")
    private Long sysAdminId;

    @ApiModelProperty("手机号码")
    private String tel;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("用户邮箱")
    private String email;

    @ApiModelProperty("用户性别")
    private SEX sex;

    @ApiModelProperty("用户头像")
    private String avatar;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("帐号状态（0正常 1停用）")
    private STATUS status;

    @ApiModelProperty("最后登录IP")
    private String loginIp;

    @ApiModelProperty("最后登录时间")
    private Date loginDate;

    @Getter
    @AllArgsConstructor
    public enum SEX implements IEnum<Integer> {
        arg0(1, "男"), arg1(2, "女");


        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static SEX getBycode(Integer code) {
            return Arrays.stream(SEX.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }

    @Getter
    @AllArgsConstructor
    public enum STATUS implements IEnum<Integer> {
        arg0(0, "正常"), arg1(1, "停用");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static STATUS getBycode(Integer code) {
            return Arrays.stream(STATUS.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }


}
